//
//  AppDelegate.m
//  LookNovel
//
//  Created by chuangqi on 2021/3/5.
//

#import "AppDelegate.h"
#import "TabBarController.h"
//#import "ADViewController.h"
#import "RW_PushPlayersTools.h"
#import <AVFoundation/AVFoundation.h>
@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [HTTPRequestTool updateBaseUrl:IPAddress];
    [self checkToken];
    
    // 1.获取音频会话
    AVAudioSession *session = [AVAudioSession sharedInstance];
    // 2.设置后台播放类别
    [session setCategory:AVAudioSessionCategoryPlayback error:nil];
    // 3.激活会话
    [session setActive:YES error:nil];
    
    [self reloadWindows];
    
    return YES;
}
-(void)reloadLaunchView{
//    ADViewController *launch = [[ADViewController alloc]init];
//    [self makeWindows:launch];
}

-(void)reloadWindows{
    TabBarController *tabbar = [[TabBarController alloc]init];
    [self makeWindows:tabbar];
}
-(void)makeWindows:(UIViewController *)vc{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = UIColor.whiteColor;
    self.window.rootViewController = vc;
    [self.window makeKeyAndVisible];
}


-(void)applicationWillResignActive:(UIApplication *)application{
    NSLog(@"应用程序将要进入非活动状态，即将进入后台");
//    [[BUPangleAdTools singletonMod] AdAppBackground];
}
- (void)applicationWillEnterForeground:(UIApplication *)application{
    NSLog(@"应用程序从后台进入前台");
//    [[BUPangleAdTools singletonMod] AdAppShow];
}


/** 刷新Token */
-(void)checkToken{
    [RW_UserModel checkToken];
}
@end
